package com.ruoyi.novel.controller;

import com.fasterxml.jackson.databind.ser.Serializers;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.novel.domain.NovelDTO;
import com.ruoyi.novel.domain.NovelVo;
import com.ruoyi.novel.service.AllBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/allBook")
public class AllBookController extends BaseController {
    @Autowired
    private AllBookService allBookService;
    /**
     * 根据前端传入的参数查询小说信息
     * 如小说类别，小说状态，更新时间，字数等
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody NovelVo novelVo){
        List<NovelDTO> novelDTOS = allBookService.selectAllBookList(novelVo);
        return getDataTable(novelDTOS);
    }
    /**
     * 根据作者和小说名查询小说信息
     */
    @GetMapping("/search")
    public TableDataInfo search(@RequestParam(required = false) String authNameOrNovelName){
        List<NovelDTO> novelDTOS = allBookService.selectNovelByAuthorOrName(authNameOrNovelName);
        return getDataTable(novelDTOS);
    }

}
